<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>幽灵按钮</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    
    #box{
      position: relative;
      width: 300px;
      height: 200px;
      margin: 50px auto;
      background-color: hotpink;
      text-align: center;
      line-height: 200px;
      font-size: 40px;
      color: yellowgreen;
      transition: 2s;
    }
    #box .top{
      position: absolute;
      top: 0;
      left: 0;
      width: 300px;
      height: 30px;
      background-color: deepskyblue;
      transition: 2s;
    }
    #box .bottom{
      position: absolute;
      bottom: 0;
      right: 0;
      width: 300px;
      height: 30px;
      background-color: deepskyblue;
      transition: 2s;
    }
  </style>
</head>
<body>
  <div id="box">
    谭松韵
    <div class="top"></div>
    <div class="bottom"></div>
  </div>
  
  <script>
    var box = document.getElementById("box");
    var top1 = document.querySelector("#box .top");
    var bottom1 = document.querySelector("#box .bottom");
    
    box.onmouseenter = function () {
      top1.style.width = '300px';
      bottom1.style.width = '300px';
      this.style.color = 'hotpink';
      this.style.backgroundColor = 'greenyellow';
    }

    box.onmouseleave = function () {
      top1.style.width = '0';
      bottom1.style.width = '0';
      this.style.color = 'greenyellow';
      this.style.backgroundColor = 'hotpink';
    }
  </script>
</body>
</html>